<template>
  <div class="home_container">
    <div class="home_nav">
      <van-search
        class="home_search"
        v-model="value"
        shape="round"
        background="#fff"
        placeholder="请输入搜索关键词"
      />
      <van-tabs>
        <van-tab v-for="(item,index) in navs" :title="item.cname" :key="index"></van-tab>
      </van-tabs>
    </div>

    <div class="home_wrapper">
      <div
        @click="goDetails(item.id)"
        class="home_goodlist"
        v-for="(item,index) in goods"
        :key="index"
      >
        <img width="100%" :src="item.mainPic" alt />
        <p class="van-multi-ellipsis--l2">{{item.title}}</p>
        <p style="color:red;font-size:0.15rem;margin:.1rem;">
          <span>
            ￥
            <span style="color:red;font-size:0.24rem;">{{item.actualPrice}} &nbsp;&nbsp;</span>

            <s style="color:grey;font-size:0.15rem;">￥{{item.originalPrice}}</s>
          </span>

          <span></span>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import REM from "../utills/rem";
export default {
  data() {
    return {
      value: ""
    };
  },
  mounted() {
    REM.Rem();
    this.$store.dispatch("getCategory");
    this.$store.dispatch("getGoods");
  },
  computed: {
    navs: function() {
      return this.$store.state.homeModule.navs;
    },
    goods: function() {
      return this.$store.state.homeModule.goods;
    },
   
  },
  methods: {
    goDetails(id) {
      console.log(id);
      this.$router.push({
        path: "/details",
        query: {
          id
        }
      });
    }
  }
};
</script>

<style scoped>
.home_container {
  width: 100%;
  background-color: rgb(243, 239, 239);
}
.home_search {
  width: 100%;
  border-bottom: 1px solid lightgrey;
}
.home_nav {
  width: 100%;
  background-color: #fff;
  position: fixed;
  top: 0px;
  left: 0px;
}
.home_wrapper {
  width: 100%;
  margin-top: 1.7rem;
  font-size: 0.3rem;
  background-color: #fff;
  box-sizing: border-box;
  padding: 0.1rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}
.home_goodlist {
  width: 49%;
  border: 1px solid lightgrey;
  font-size: 0.2rem;
  margin-bottom: 0.1rem;
}
</style>